package com.bph.commons.utils;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;

public class CookieValue {
    public static String getCookieValue(HttpServletRequest request, String name) {
        String ticket = null;
        //获取cookie数组
        Cookie[] cookie = request.getCookies();
        //遍历数组,获取ticket
        for (int i = 0; i < cookie.length; i++) {
            String ticketName = cookie[i].getName();
            if (ticketName.equals(name)) {
                ticket = cookie[i].getValue();
                break;
            }
        }
        return ticket;
    }
}
